package com.duan.service.role;

import com.alibaba.fastjson.parser.deserializer.SqlDateDeserializer;
import com.duan.dao.role.RoleDao;
import com.duan.dao.role.RoleDaoImpl;
import com.duan.pojo.Role;
import com.duan.dao.baseDao;
import org.junit.Test;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;

public class RoleServiceImpl implements RoleService{
    //引入Dao
    private RoleDao roleDao;
    public RoleServiceImpl(){
        roleDao = new RoleDaoImpl();
    }


    //获取角色列表
    public List<Role> getRoleList() {

        Connection connection = null;
        List<Role> roleList = null;

        try{
            connection = baseDao.getConnection();
            roleList = roleDao.getRoleList(connection);
        }catch (SQLException e){
            e.printStackTrace();
        }finally {
            baseDao.closeResource(connection, null, null);
        }

        return roleList;
    }

//    @Test
//    public void test(){
//        RoleServiceImpl roleService = new RoleServiceImpl();
//        List<Role> roleList = roleService.getRoleList();
//        for (Role role : roleList) {
//            System.out.println(role.getRoleName());
//        }
//    }
}
